Basic tutorial for the C/C++ programming language.
The presentation from Dr. Crawford and his example programs can be found at:
http://www.pa.uky.edu/~crawford/cpp/
A general C++ tutorial can be found at:
http://cplusplus.com/doc/tutorial/
Instructions for compiling c++ source code on Windows from the command line:
- After placing the source codes in a folder on your computer, you need to compile your source codes.
- In order to do this, go to the "Visual C++ Command Prompt". You may need to run the command prompt as an administrator (right click, select "Run as Administrator").
- When you run the command prompt as the administrator, you'll get a line within the prompt window as "C:\Windows\system32>", but you will need to change this directory by inputting the following command: cd newdirectory (where the newdirectory is the path name to the folder where you've stored your source codes).
- Another line will appear in the command prompt and it will now be the path name to the new directory, where you can now input the command:
- "cl sourcecodes.cc -o nameofprogram.exe" where cl is the command to envoke the compiler/ linker to assemble all sourcecodes that are typed in between the command and -o, and the nameofprogram is the name that you would like to name your new executable file.
- After the code has been generated, you can now run the executable code by placing the nameofprogram.exe in the next line.
A specific example:
1) Download hist_r.cc hist_t.cc hist_t.h hist_x.cc from
http://www.pa.uky.edu/~crawford/cpp/ and save the files to a folder on your computer. For this example the files have been downloaded into a folder on the desktop.
2) Locate and run "Visual Studio 2008 Command Prompt" as administrator. The first line on the command prompt is:
3) Because the files have been placed on the desktop, you need to tell the command prompt where to find the files by changing the directory. This can be done by:
- C:\Windows\system32>cd C:\Users\User\Desktop\code\histogram (where User has to replaced by your own username and histogram is the folder you created)
4) This command has changed the directory, so the next line in the command prompt will be
- C:\Users\User\Desktop\code\histogram>
5) To compile the program by input commands on this line:
- C:\Users\User\Desktop\code\histogram>cl hist_t.cc hist_x.cc -o hist.exe
6) You should now see "Generating code", and once it has completed, the next line should be
- C:\Users\User\Desktop\code\histogram>
7) And now to test the program:
- C:\Users\User\Desktop\code\histogram>hist.exe